#include "barrier.h"
#include "ui_barrier.h"
#include <iostream>

Barrier::Barrier(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Barrier)
{
    ui->setupUi(this);
    t1Id = startTimer(1000);
    barrier_tf.push_back(1.5);
    barrier_tf.push_back(1.5);
    barrier_tf.push_back(1.5);
    num = 1;
}

Barrier::~Barrier()
{
    delete ui;
}

void Barrier::on_pushButton_clicked()
{
    if(num>10){
        ui->notion->setText("");
        //  发送程序
    }
    else {
        ui->notion->setText("不在射程范围内！");
    }
}
void Barrier::timerEvent(QTimerEvent *e)
{

    if(e->timerId() == t1Id){
        update_tf(std::vector<double> {num++, num++, num});
        if(num>10)//condition
        {
            ui->pushButton->setStyleSheet("color:green");
        }
        else {
            ui->pushButton->setStyleSheet("color:red");
        }
        ui->barrier_x->setText(QString::number(barrier_tf[0]));
        ui->barrier_y->setText(QString::number(barrier_tf[1]));
        ui->barrier_z->setText(QString::number(barrier_tf[2]));
    }
}
void Barrier::update_tf(std::vector<double> _new_tf)
{
    barrier_tf.clear();
    barrier_tf = _new_tf;
}
